<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.util.*" %>
<%@ page import="com.ionglobal.db.*" %>
<%@ page import="com.ionglobal.lib.*" %>
<%@ page import="com.ionglobal.misc.*" %>

<%@ include file="../init_include.jsp" %>

<%
	Category cat;
	Integer catId;
	int totalpages,pageid=0;
	int pagerows=Page.getPageRows();
	int totalrows=0;
  String ordermode="desc";
  String orderfield="sysop.id";
	
	int check_rst=Permission.accept(dbi,session,request,"sysop","tree","catid","000000010"); 

	if(request.getParameter("ordermode")!=null)
		ordermode=request.getParameter("ordermode");	
	if(request.getParameter("orderfield")!=null)
		orderfield=request.getParameter("orderfield");	
	
	if (check_rst!=Permission.CHECK_RST_SUCCESS)
	{
		dbi.closeAll();
		if (check_rst==Permission.CHECK_RST_DENY)
			response.sendRedirect("../deny.html");
		else
			response.sendRedirect("../index.jsp");
		return;		
	}	
	
	String a=request.getParameter("catid");
	String str="";
	try {
		catId=Integer.valueOf(a);		
	} catch(NumberFormatException e) {
		out.println(e+"catId");
		return;
	}
	
	try {
		if (request.getParameter("pageid")!=null)
			pageid=Integer.parseInt(request.getParameter("pageid"));
	} catch(NumberFormatException e) {
		out.println(e+"pageid");
	}	
	
	try {
		if (request.getParameter("pagerows")!=null)
			pagerows=Integer.parseInt(request.getParameter("pagerows"));
	} catch(NumberFormatException e) {
		out.println(e+"pagerows");
	}	

	cat=new Category(dbi,catId.intValue());
	a=cat.getName();
	int departid=0;
	if(request.getParameter("departid")!=null)
		departid=Integer.parseInt(request.getParameter("departid"));

	String whereClause="";
	if(request.getParameter("whereClause")!=null)
		whereClause=request.getParameter("whereClause");	
	whereClause=whereClause.trim();

	totalrows=Department.getNoDepartUsersNum(dbi,departid,whereClause);
	totalpages = (int)Math.ceil((double)totalrows/pagerows);
	if(pageid>totalpages)
		pageid=totalpages;
	if(pageid<=1)
		pageid=1;
%>	
<html>
<head>
<title><%=Language.getNameByCode("sys.depart.moveuser","Move user to current department")%></title>
<meta http-equiv="Content-Type" content="text/html; charset=<%=Language.getHTMLLanguageStr()%>">
<link rel="stylesheet" href="../css.css" type="text/css">
<SCRIPT language=JavaScript1.2 src="../script/Ion_Show.js"></SCRIPT>
<script language="javascript">
	function moveUser()
	{
		var selectitem=selectlist();
		location.href="sys_depart_user_mov.jsp?catid="+window.formIon.catid.value+"&departid="+window.formIon.departid.value+"&idtext="+selectitem;
	}		
				
	function Ion_Search()
	{
		add_Ion('vmsSelectFrame.jsp','../ums/sysop_search.jsp','userid',"search_user");
	}
				
</script>
</head>

<body bgColor=#d6d3ce leftMargin=0 
style="BORDER-BOTTOM: 0px outset; BORDER-LEFT: 0px outset; BORDER-RIGHT: 0px outset; BORDER-TOP: 0px outset" 
topMargin=0>

	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<FORM name="formIon" method="post" action="sys_depart_user_dj.jsp">
   	<tr>
    	<td>
    		<%=Language.getNameByCode("sys.depart.UserList","Userlist in department")%><%=PageStr.getPageHead(totalrows,pageid,pagerows,totalpages)%>
    		&nbsp;&nbsp;<% if(whereClause!=null && whereClause.length()>0) {%><a href="javascript:stopSearch();"><%=Language.getNameByCode("sys.clearsearch","Clear Search Condition")%></a><%}%>    		
    	</td>
     	<td align=right>
     		<%=PageStr.PageForm(pageid,totalpages)%><input type="submit" name="Submit" value="go" style="width:0">
      </td>
   	</tr>
	</table>

	<TABLE border=0 cellPadding=0 cellSpacing=1 height="100%" width="100%">
		<input type="hidden" name="catid" value="<%=catId%>">
		<input type="hidden" name="departid" value="<%=departid%>">
		<input type="hidden" name="whereClause" value="<%=whereClause%>">		
		<INPUT name="objid" type="hidden">
		<INPUT name="objtext" type="hidden">
		<INPUT name="actionurl" type="hidden">
		<input type="hidden" name="orderfield" value="<%=orderfield%>">
		<input type="hidden" name="ordermode" value="<%=ordermode%>">
  	<TR>
    <TD>
   <%
    
   Table table=new Table();
   table.setSortMode(ordermode);
   table.setSortField(orderfield);
   table.setSelectionMode("multiple");

   table.addColumn("no","sysop.id",0,"center","left","number");
   table.addColumn(Language.getNameByCode("sys.sysop.id","ID"),"sysop.id",30,"center","left","text");
   table.addColumn(Language.getNameByCode("sys.sysop.name","Name"),"sysop.name",100,"center","left","text");
   table.addColumn(Language.getNameByCode("sys.sysop.fullname","FullName"),"sysop.fullname",100,"center","left","text");
   table.addColumn(Language.getNameByCode("sys.sysop.status","Status"),"sysop.status",70,"center","center","text");
   table.addColumn(Language.getNameByCode("sys.sysop.depart","Department"),"sysop.departid",80,"center","left","text");
   table.addColumn(Language.getNameByCode("sys.sysop.email","Email"),"sysop.email",70,"center","right","text");

    ArrayList rowsList=new ArrayList();
    try {
     Vector vc=new Vector();
     String statusstr[]=StaticDim.getUserStatus();
	 vc=Department.getNoDepartUsers(dbi,departid,whereClause,pageid,pagerows,orderfield,ordermode);
	 Sysop c;	
     String rowData="";
     for(int i=0;i<vc.size();i++) {
      c=(Sysop)vc.get(i);
      rowData=c.getId()+"|"+c.getId()+"|"+c.getName()+"|"+StringUtil.chargeNull(c.getFullName())+"|"+statusstr[c.getStatus()]+((c.getStatus()==1 && c.getExpire()!=null) ? c.getExpire().toString() : "")+"|"+c.getDepartName()+"|"+c.getEmail();
      rowsList.add(rowData);
     }
    } catch(Exception E) {
    }
	dbi.rsClose();

    ArrayList menuList=new ArrayList();
    TableMenu tm=null;

    tm=new TableMenu(Language.getNameByCode("sys.depart.moveuser","Move user to current department"),"javascript:moveUser();",true);
    menuList.add(tm);
    tm=new TableMenu(Language.getNameByCode("sys.Head.Refresh","Refresh"),"",true);
    menuList.add(tm);
    tm=new TableMenu(Language.getNameByCode("sys.sysop.search","Search User"),"javascript:Ion_Search();",false);
    menuList.add(tm);    

    table.setTableMenu(menuList);
    table.setRowsList(rowsList);
    TableDB tdb=new TableDB();
    out.print(tdb.draw(table));
    %>

	  </TD>
 	</TR>
 	</FORM>
	</TABLE>
</body>
</html>
<%@ include file="../init_free.jsp" %>	
